<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Merchant_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-merchant_id" data-rule="required" data-source="merchant/index" data-primary-key="id" data-field="company_name" class="form-control selectpage" name="row[merchant_id]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Store_name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-store_name" data-rule="required" class="form-control" name="row[store_name]" type="text" value="">
        </div>
    </div>
    <!--<div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('User_id')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-user_id" data-rule="required" data-source="user/user/index" data-field="nickname" class="form-control selectpage" name="row[user_id]" type="text" value="">
        </div>
    </div>-->
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Mobile')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-mobile" data-rule="required" class="form-control" name="row[mobile]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-name" data-rule="required" class="form-control" name="row[name]" type="text" value="">
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">戳它 --></label>
        <div class="col-xs-12 col-sm-8">
            <button type="button" class="btn btn-primary" data-toggle="addresspicker" data-input-id="c-address" data-lng-id="c-long" data-lat-id="c-lat">点击选择地址获取经纬度</button>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-address" data-rule="required" class="form-control" name="row[address]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Long')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-long" data-rule="required" class="form-control" step="0.00000001" name="row[long]" type="number" value="0.00000000">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Lat')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-lat" data-rule="required" class="form-control" step="0.00000001" name="row[lat]" type="number" value="0.00000000" onchange="getMaxRate()">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">返点率提示:</label>
        <div class="col-xs-12 col-sm-8">
            <label class="control-label" id="rate-tip" style="color:red;">当前代理区代理最大返点率为:0.00,代理返点 + 门店返点 <= 100 </label>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">组队返点率:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-rate" data-rule="required" class="form-control" step="0.01" name="row[rate]" type="number" value="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">助教分成率:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-assistant_rate" data-rule="required" class="form-control" step="0.01" name="row[assistant_rate]" type="number" value="0.00">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Business_licence')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-business_licence" data-rule="required" class="form-control" size="50" name="row[business_licence]" type="text" value="">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-business_licence" class="btn btn-danger faupload" data-input-id="c-business_licence" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-business_licence"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-business_licence" class="btn btn-primary fachoose" data-input-id="c-business_licence" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-business_licence"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-business_licence"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Tel_phone')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-tel_phone" data-rule="required" class="form-control" name="row[tel_phone]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Background_image')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-background_image" data-rule="required" class="form-control" size="50" name="row[background_image]" type="text" value="">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-background_image" class="btn btn-danger faupload" data-input-id="c-background_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-background_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-background_image" class="btn btn-primary fachoose" data-input-id="c-background_image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-background_image"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-background_image"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Business_start_hours')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-business_start_hours" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-use-current="true" data-rule="required" class="form-control" name="row[business_start_hours]" type="text" value="0">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Business_end_hours')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-business_end_hours" class="form-control datetimepicker" data-date-format="HH:mm:ss" data-use-current="true" data-rule="required" class="form-control" name="row[business_end_hours]" type="text" value="0">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
        <div class="col-xs-12 col-sm-8">
            
            <div class="radio">
            {foreach name="statusList" item="vo"}
            <label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="1"}checked{/in} /> {$vo}</label> 
            {/foreach}
            </div>

        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Level')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-level" data-rule="required" data-source="level/index" data-field="vip_name" data-primary-key="vl_id" class="form-control selectpage" name="row[level]" type="text" value="">
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Banner_image')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-banner_image" data-rule="required" class="form-control" size="50" name="row[banner_image]" type="text" value="">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-banner_image" class="btn btn-danger faupload" data-input-id="c-banner_image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-banner_image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-banner_image" class="btn btn-primary fachoose" data-input-id="c-banner_image" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-banner_image"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-banner_image"></ul>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Icon')}:</label>
        <div class="col-xs-12 col-sm-8">
            <div class="input-group">
                <input id="c-icon" data-rule="required" class="form-control" size="50" name="row[icon]" type="text" value="">
                <div class="input-group-addon no-border no-padding">
                    <span><button type="button" id="faupload-icon" class="btn btn-danger faupload" data-input-id="c-icon" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-icon"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
                    <span><button type="button" id="fachoose-icon" class="btn btn-primary fachoose" data-input-id="c-icon" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
                </div>
                <span class="msg-box n-right" for="c-icon"></span>
            </div>
            <ul class="row list-inline faupload-preview" id="p-icon"></ul>
        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Description')}:</label>
        <div class="col-xs-12 col-sm-8">
            <textarea id="c-description" class="form-control " rows="5" name="row[description]" cols="50"></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">免费服务:</label>
        <div class="col-xs-12 col-sm-8">
            <input type="text" class="form-control" name="row[narrate]" data-role='tagsinput' value=""/>
        </div>
    </div>

    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Organizeable')}:</label>
        <div class="col-xs-12 col-sm-8">
                        
            <select  id="c-organizeable" data-rule="required" class="form-control selectpicker" name="row[organizeable]">
                {foreach name="organizeableList" item="vo"}
                    <option value="{$key}" {in name="key" value="1"}selected{/in}>{$vo}</option>
                {/foreach}
            </select>

        </div>
    </div>
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('Max_person')}:</label>
        <div class="col-xs-12 col-sm-8">
            <input id="c-max_person" data-rule="required" class="form-control" name="row[max_person]" type="number" value="0">
        </div>
    </div>
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
        </div>
    </div>
</form>
<script>
    function getMaxRate() {
        var lat = $('#c-lat').val();
        var lng = $('#c-long').val();
        if (lat && lng) {
            $.get("{:url('ajax/maxProxyRate')}", {lat: lat, lng: lng}, function (res) {
                $("#rate-tip").val('当前代理区最大代理返点率为:'+ res.data.max_rate +',代理返点 + 门店返点 <= 100' );
            });
        }
    }
</script>